#include <REGX52.H>
#include "IR.h"
#include "Delay.h"
#include "Motor.h"
#include "Nixie.h"

unsigned char Key, Com, Speed;

void main()
{
	IR_Init();
	Motor_Init();
	LightNixieTube(1, 0);
    while(1)
    {
		if(IR_DataReady() || IR_GetRepeatFlag())
		{
			Com = IR_GetCommand();
			if(Com == IR_VOL_MINUS)
				Speed = Speed == 0 ? 3 : --Speed;
			else if(Com == IR_VOL_ADD)
				Speed = (Speed + 1) % 4;
			
			if(Speed == 0) { Motor_SetSpeed(0); }
			if(Speed == 1) { Motor_SetSpeed(50); }
			if(Speed == 2) { Motor_SetSpeed(75); }
			if(Speed == 3) { Motor_SetSpeed(100); }
			LightNixieTube(1, Speed);
		}
		Delayms(10);
    }
}